//
//  ListTableViewCell1.m
//  HimalayaMusic
//
//  Created by dllo on 16/1/7.
//  Copyright © 2016年 WXCLegendary. All rights reserved.
//

#import "ListTableViewCell1.h"

@implementation ListTableViewCell1

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.clipsToBounds = YES;
        self.imageViews = [[UIImageView alloc] init];
        self.titleLabel = [[UILabel alloc] init];
        self.likeLabel = [[UILabel alloc] init];
        self.playLabel = [[UILabel alloc] init];
        self.numberLabel = [[UILabel alloc] init];
        [self addSubview:self.imageViews];
        [self addSubview:self.titleLabel];
        [self addSubview:self.playLabel];
        [self addSubview:self.likeLabel];
        [self addSubview:self.numberLabel];
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    self.numberLabel.frame = CGRectMake(5, 5, 10, self.height - 10);

    self.imageViews.frame = CGRectMake(20, 5, self.height - 20, self.height - 10);
    self.titleLabel.frame = CGRectMake(self.imageViews.origin.x + self.imageViews.width + 5, 5, self.width - 20 - self.imageViews.width - 20, (self.height - 20) / 2 );
    self.playLabel.frame = CGRectMake(self.titleLabel.origin.x, self.titleLabel.origin.y + self.titleLabel.height + 10, self.titleLabel.width / 2 , self.titleLabel.height);
    self.likeLabel.frame = CGRectMake(self.playLabel.origin.x + self.playLabel.width + 5, self.playLabel.origin.y, self.titleLabel.width / 2, self.titleLabel .height);
    
}

-(void)setModel:(listDetailModel1 *)model {
    if (_model != model) {
        _model = model;
    }
    [self.imageViews sd_setImageWithURL:[NSURL URLWithString:model.coverSmall]];
    
    self.numberLabel.text = self.string ;

    self.numberLabel.textColor = [UIColor colorWithRed:arc4random() % 254 / 256.0 green:arc4random() % 255 / 256.0 blue:arc4random() % 255 / 256.0 alpha:1];
    self.titleLabel.text = model.title;
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.font = [UIFont systemFontOfSize:14];
    
    self.playLabel.text = [NSString stringWithFormat:@"播放:%@",[HeperTools SharePlayCount:[model.playsCounts intValue]]];
    self.playLabel.font = [UIFont systemFontOfSize:12];
    self.playLabel.textColor = [UIColor grayColor];
    
    self.likeLabel.text = [NSString stringWithFormat:@"喜欢:%@", [model.favoritesCounts stringValue]];
    self.likeLabel.font = [UIFont systemFontOfSize:12];
    self.likeLabel.textColor = [UIColor grayColor];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
